You are here: Programming guide > COM SDK fundamentals > Sample code > Searching document content

Searching document content

The sample code below demonstrates how to perform searches on document content from an interface extension.

Example

Private Sub Doit(ByVal dr As AMDocumentRepository)
Dim ps As AMPropertySet
Dim pd1 As AMPropertyDef
Dim pd2 As AMPropertyDef
Dim sq As AMSearchQuery
Dim pf1 As AMPropertyFilter
Dim pf2 As AMPropertyFilter
Dim tv As AMTableViewROCollection
Dim itv As IAMTableView
Dim vv As Variant
Set ps = dr.Environment.PropertySets("AMContentSearchPropertySet")
Set pd1 = ps.GetPropertyDefWithName("_SEARCHDOCUMENTCONTENT")  ' only content of the document file '
Set pd1 = ps.GetPropertyDefWithName("_SEARCHTEXTANDMEMOFIELDS") ' all text andmemo properties '
Set pd1 = ps.GetPropertyDefWithName("_SEARCHTEXTANDALLCONTENT") ' all text and memo properties and document content
Set pd2 = ps.GetPropertyDefWithName("_SEARCHMEMOFIELDS") ' only memo properties
Set sq = dr.NewSearchQuery sq.DisplayNameWildCard = "*.*"
Set pf1 = sq.NewPropertyFilter
With pf1
Set .Property = pd1 ' do not set it if you want to search in<All text properties>
.Operator = OP_CONTAINS
.Value = "Meridian"
End With
Set pf2 = sq.NewPropertyFilter
With pf2 Set .Property = pd2
.Operator = OP_CONTAINS
.Value = dr.User
End With
Set tv = dr.ExecuteQuery(sq)
Set itv = tv
vv = itv.GetMultipleRowColumns(0, -1)
End Sub

www.bluecieloecm.com